<!DOCTYPE html>
<%@ page import="rentadomus.Place" %>  
<%@ page import="rentadomus.Warehouse" %>  
<%@ page import="rentadomus.Office" %>  
<%@ page import="rentadomus.Local" %>  
<%@ page import="rentadomus.Apartament" %>  
<%@ page import="rentadomus.Dwelling" %>  
<%@ page import="rentadomus.House" %>  
<html>
  <head>
    <meta name="layout" content="main"/><!--esta linea es para mostrar el contenido en main-->
    <title>Home - RentADomus</title>
  </head>
  <body  BGCOLOR="red">
    <div class="message" role="status">${flash.message}</div>
    <g:if test="${!session.person}">
      <g:form name="BLogin" controller="login">
        <fieldset class="buttons">
            <g:submitButton name="login" value="Log in"/>
          </fieldset>
      </g:form>
      <g:form name ="Bcreate" url="[controller:'person', action:'create']">
        <fieldset class="buttons">
          <g:submitButton name="signUp" value="Sign up"/>
         </fieldset> 
       </g:form>      
    </g:if>
    <g:else>
      <g:if test="${!session.person.name.equals("")}">
        <g:form name ="Bpl" url="[controller:'placeRedirect', action:'index']">
          <fieldset class="buttons">
            <g:submitButton name="createPlace" value="Create new Place"/>
           </fieldset> 
         </g:form>          
      </g:if>
      <g:form name ="Bsearch" url="[controller:'listPlace', action:'index']">
        <fieldset class="buttons">
          <g:submitButton name="listPlace" value="List Places"/>
         </fieldset> 
       </g:form>  
      <g:form name ="BContracts" url="[controller:'contract', action:'list']">
        <fieldset class="buttons">
          <g:submitButton name="contract" value="Contracts"/>
         </fieldset> 
       </g:form>  
      <g:form name ="BPqr" url="[controller:'pqr', action:'index']">
        <fieldset class="buttons">
          <g:submitButton name="pqr" value="PQR"/>
         </fieldset> 
       </g:form>  
      <g:form name ="Blogout" url="[controller:'login', action:'logout']">
        <fieldset class="buttons">
          <g:submitButton name="logout" value="Log out"/>
         </fieldset> 
       </g:form>        
    </g:else>
  <g:each in="${Place.findAll(sort: 'date', order:'desc')}" status="i" var="it">
        <g:each in="${Warehouse.findAll()}" status="j" var="ot">          
          <g:if test="${ot.idPlace.id == it.id}">
            <p>
           <g:if test="${it.mainImage != 0}">
            <a href="${createLink(controller:"Warehouse", action:'show', id:ot.id)}"><img class="normal" src="${createLink(controller:'UploadImage', action:'displayImage', id:(int)it.mainImage)}" /> </a>
           </g:if>
            <g:else>
              <!--<img src="/RentADomus/static/images/banner.jpg" />-->
            </g:else>
            </p>     
            <p><a href="${createLink(controller:"Warehouse", action:'show', id:ot.id)}">${it.titlePlace}</a></p>                    
         </g:if>
       </g:each>        
        
        <g:each in="${Office.findAll()}" status="j" var="ot">          
          <g:if test="${ot.idPlace.id == it.id}">
            <p>
           <g:if test="${it.mainImage != 0}">
            <a href="${createLink(controller:"Office", action:'show', id:ot.id)}"><img class="normal" src="${createLink(controller:'UploadImage', action:'displayImage', id:(int)it.mainImage)}" /> </a>
           </g:if>
            <g:else>
              <!--<img src="/RentADomus/static/images/banner.jpg" />-->
            </g:else>            
            </p>     
            <p><a href="${createLink(controller:"Office", action:'show', id:ot.id)}">${it.titlePlace}</a></p>                    
         </g:if>
       </g:each>        

        
        <g:each in="${Local.findAll()}" status="j" var="ot">          
          <g:if test="${ot.idPlace.id == it.id}">
            <p>
           <g:if test="${it.mainImage != 0}">
            <a href="${createLink(controller:"Local", action:'show', id:ot.id)}"><img class="normal" src="${createLink(controller:'UploadImage', action:'displayImage', id:(int)it.mainImage)}" /> </a>
           </g:if>
            <g:else>
              <!--<img src="/RentADomus/static/images/banner.jpg" />-->
            </g:else>            
            </p>     
            <p><a href="${createLink(controller:"Local", action:'show', id:ot.id)}">${it.titlePlace}</a></p>                    
         </g:if>
       </g:each>        
        
        <g:each in="${Dwelling.findAll()}" status="j" var="ot">          
          <g:if test="${ot.idPlace.id == it.id}">
            <g:each in="${Apartament.findAll()}" status="k" var="at">          
              <g:if test="${ot.id == at.idDwelling.id}">            
                <p>
               <g:if test="${it.mainImage != 0}">
                <a href="${createLink(controller:"Apartament", action:'show', id:ot.id)}"><img class="normal" src="${createLink(controller:'UploadImage', action:'displayImage', id:(int)it.mainImage)}" /> </a>
               </g:if>
            <g:else>
              <!--<img src="/RentADomus/static/images/banner.jpg" />-->
            </g:else>                
                </p>     
                <p><a href="${createLink(controller:"Apartament", action:'show', id:ot.id)}">${it.titlePlace}</a></p>                    
              </g:if>
            </g:each>
         </g:if>
       </g:each>          

        <g:each in="${Dwelling.findAll()}" status="j" var="ot">          
          <g:if test="${ot.idPlace.id == it.id}">
            <g:each in="${House.findAll()}" status="k" var="at">          
              <g:if test="${ot.id == at.idDwelling.id}">            
                <p>
               <g:if test="${it.mainImage != 0}">
                <a href="${createLink(controller:"House", action:'show', id:ot.id)}"><img class="normal" src="${createLink(controller:'UploadImage', action:'displayImage', id:(int)it.mainImage)}" /> </a>
               </g:if>
            <g:else>
              <!--<img src="/RentADomus/static/images/banner.jpg" />-->
            </g:else>                
                </p>     
                <p><a href="${createLink(controller:"House", action:'show', id:ot.id)}">${it.titlePlace}</a></p>                    
              </g:if>
            </g:each>
         </g:if>
       </g:each>          
        
     </g:each>    

  </body>
</html>



